package com.junjie.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderConsulController {
    //远程调用的 地址(这里的名字要注意：不能写 http://localhost:8006)
    public static final String PAYMENY_URL = "http://consul-provider-payment";

    //这里还可以用 Inject
    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/customer/payment/consul")
    public String getPaymentById(){
        return restTemplate.getForObject(PAYMENY_URL + "/payment/consul" , String.class);
    }
}
